package com.example.shop.modules.manage.controller;


import com.example.shop.modules.manage.service.IFreightAdminService;
import com.example.shop.persistence.entity.Freight;
import com.example.shop.utils.JSONResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.example.shop.utils.JSONResult.renderSuccess;

/**
 * <p>
 * 运费表 前端控制器
 * </p>
 *
 * @author jason
 * @since 2020-12-02
 */
@Api(tags = "后台接口运费表")
@RestController
@RequestMapping("/manage/freight")
public class FreightAdminController {

    @Autowired
    private IFreightAdminService freightService;

    @PostMapping
    @ApiOperation(value = "新增或修改")
    public JSONResult addFreight(Freight freight){
        return renderSuccess(freightService.saveOrUpdate(freight));
    }

    @DeleteMapping
    @ApiOperation(value = "删除")
    public JSONResult deleteFreight(String ids){
        return renderSuccess(freightService.deleteFreight(ids));
    }

    @GetMapping
    @ApiOperation(value = "查询")
    public JSONResult getFreight(){
        return renderSuccess(freightService.list());
    }
}

